﻿using System;
using System.Collections.Generic;

using System.Text;
using wrzy.utll;
using System.Data.SqlClient;
using System.Threading;

namespace wrzy
{
    /// <summary>
    /// 托盘对象
    /// </summary>
    class tp
    {
        public tp()
        { }
        /// <summary>
        /// 托管是否准备好
        /// </summary>
        /// <returns></returns>
        public Boolean TpStatus()
        {
            int status;
            sqlServer tpData = new sqlServer();
            SqlDataReader TpReader = tpData.ExecuteReader("select tpReady from zyprocStatus ");
            TpReader.Read();
            status = (int)TpReader.GetValue(0);
            TpReader.Close();
            if (status == 1)
                return true;
            else
                return false;
        }
        /// <summary>
        /// 一号拖盘是否给料完成
        /// </summary>
        /// <returns></returns>
        public Boolean FirstFin()
        {
            int status;
            sqlServer tpData = new sqlServer();
            SqlDataReader TpReader = tpData.ExecuteReader("select FirtpFin from zyprocStatus ");
            LOG.write("select FirtpFin from zyprocStatus ");
            TpReader.Read();
            status = (int)TpReader.GetValue(0);
            TpReader.Close();
            if (status == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 二号拖盘是否完成给料操作
        /// </summary>
        /// <returns></returns>
        public Boolean SecpFin()
        {
            int status;
            sqlServer tpData = new sqlServer();
            SqlDataReader TpReader = tpData.ExecuteReader("select SectpFin from zyprocStatus ");
            TpReader.Read();
            status = (int)TpReader.GetValue(0);
            TpReader.Close();
            if (status == 1)
            {
                return true;
                LOG.write("select SectpFin from zyprocStatus  ");
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 第一次给煤
        /// </summary>
        public void Firdrop(int status)
        {
            sqlServer drop = new sqlServer();
            drop.ExecuteSql("update zystatus set Firdrop="+status);
            LOG.write("update zystatus set Firdrop=" + status);
        }
        /// <summary>
        /// 二次给煤
        /// </summary>
        public void Secdrop(int status)
        {
            sqlServer drop = new sqlServer();
            if (status == 1)
            {
                drop.ExecuteSql("update zystatus set firdrop=0,Secdrop=1");
            }
            LOG.write("update zystatus set firdrop=0,Secdrop=1");
            if (status == 0)
            {
                drop.ExecuteSql("update zystatus set Secdrop=0");
            }
        }
    }
}
    